name:  run linters and tests
on:
  pull_request:
  push:
    branches:
      - master

env:
  GOPROXY: 'https://proxy.golang.org/cached-only'
  IGNITE_VERSION: 2.16.0
  IGNITE_HOME: /opt/ignite

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install go toolchain
        uses: actions/setup-go@v3
        with:
            go-version: '1.19'
      - name: Install jdk
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '11'
      - name: Run linters
        run : |
          make lint
      - name: Install Apache Ignite
        run: |
          curl -L https://apache-mirror.rbc.ru/pub/apache/ignite/${IGNITE_VERSION}/apache-ignite-slim-${IGNITE_VERSION}-bin.zip > ignite.zip
          unzip ignite.zip -d /opt
          mv /opt/apache-ignite-slim-${IGNITE_VERSION}-bin /opt/ignite
          mv /opt/ignite/libs/optional/ignite-log4j2 /opt/ignite/libs/
      - name: Run tests
        run: |
          make test
# Upload artifacts doesn't work on gitverse yet :(.
#      - name: Save artifacts
#        uses: actions/upload-artifact@v3
#        with:
#          name: test-results
#          path: |
#            ./internal/testing/config/ignite-config-*.xml
#            ./internal/testing/logs/ignite-log-*.txt
#            ./coverage.out
#            ./test-report.xml

